<template>
  <el-dialog
    v-model="visible"
    title="切片方法"
    width="50%"
    :close-on-click-modal="false"
    @close="handleClose"
  >
    <el-form :model="form" label-width="140px">
      <el-form-item label="切片方法：">
        <el-select v-model="form.method" class="w-full">
          <el-option label="General" value="General" />
        </el-select>
      </el-form-item>

      <el-form-item label="建议文本块大小：">
        <el-slider v-model="form.blockSize" :max="1024" :step="1" show-input />
      </el-form-item>

      <el-form-item label="文本分段标识符：" required>
        <el-input v-model="form.separator" placeholder="\n" />
      </el-form-item>

      <el-form-item label="自动关键词提取：">
        <div class="flex items-center">
          <el-switch v-model="form.autoKeywordExtract" />
          <el-input-number
            v-if="form.autoKeywordExtract"
            v-model="form.keywordCount"
            :min="0"
            class="ml-4"
          />
        </div>
      </el-form-item>

      <el-form-item label="自动问题提取：">
        <div class="flex items-center">
          <el-switch v-model="form.autoQuestionExtract" />
          <el-input-number
            v-if="form.autoQuestionExtract"
            v-model="form.questionCount"
            :min="0"
            class="ml-4"
          />
        </div>
      </el-form-item>

      <el-form-item label="使用召回增强RAPTOR策略：">
        <el-switch v-model="form.useRaptor" />
      </el-form-item>

      <el-form-item label="提取知识图谱：">
        <el-switch v-model="form.extractKnowledgeGraph" />
      </el-form-item>
    </el-form>

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, reactive, computed } from 'vue'

const props = defineProps({
  modelValue: Boolean
})

const emit = defineEmits(['update:modelValue', 'confirm'])

const visible = computed({
  get: () => props.modelValue,
  set: (val) => emit('update:modelValue', val)
})

const form = reactive({
  method: 'General',
  blockSize: 512,
  separator: '\\n',
  autoKeywordExtract: false,
  keywordCount: 0,
  autoQuestionExtract: false,
  questionCount: 0,
  useRaptor: false,
  extractKnowledgeGraph: false
})

const handleClose = () => {
  visible.value = false
}

const handleConfirm = () => {
  emit('confirm', { ...form })
  visible.value = false
}
</script>

<style scoped>
.w-full {
  width: 100%;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.ml-4 {
  margin-left: 16px;
}
</style> 